import { ApiHideProperty, ApiProperty } from '@nestjs/swagger'
import { Column, Entity } from 'typeorm'
import { SoftCompleteEntity } from '~/common/entity/common.entity'
import { SubPlanEntity } from '../sub-plan/entities/sub-plan.entity'

@Entity({ name: 'c_plan_task' })
export class PlanTaskEntity extends SoftCompleteEntity {
  @Column({ name: 'task_type', default: 1, comment: '任务类型，1 读一读 2 看一看 3 玩一玩' })
  @ApiProperty({ description: '任务类型，1 读一读 2 看一看 3 玩一玩' })
  taskType: number

  @Column({ name: 'task_id', unique: true, comment: '任务ID, R/W/P+yymmdd+000' })
  @ApiProperty({ description: '任务ID, R/W/P+yymmdd+000' })
  taskId: string

  @Column({ name: 'task_name', comment: '任务名称' })
  @ApiProperty({ description: '任务名称' })
  taskName: string

  @Column({ name: 'task_mark', default: '', comment: '任务备注' })
  @ApiProperty({ description: '任务备注' })
  taskMark: string

  @Column({ name: 'resource_id', default: 0, comment: '资源关联ID，task_type=1为c_book表id，task_type=2为c_video表id' })
  @ApiProperty({ description: '资源关联ID，task_type=1为c_book表id，task_type=2为c_video表id' })
  resourceId: number

  @Column({ name: 'task_content', type: 'text', nullable: true, comment: '任务内容，使用json配置' })
  @ApiProperty({ description: '任务内容，使用json配置' })
  taskContent: string

  // 非数据库字段，只用于 service 里逻辑填充
  @ApiHideProperty()
  subPlans?: SubPlanEntity[]
}
